<div class="panel panel-default">
	<div class="panel-body">
		<div class="row">
			<div class="col-lg-4">
	    		<button class="mb-sm btn btn-primary btn-outline" type="button" (click)="checkBtn()">
					{{('account.adjustaccount.adjustment' | translate) || '调 账'}}
				</button>
	    		<button class="mb-sm btn btn-primary btn-outline" type="button" (click)="adjustRecords.show();searchAdjustRecords()" style="margin-left:15px;">
					{{('account.adjustaccount.adjustmentSearch' | translate) || '调账记录查询'}}
				</button>
	    	</div>
	    	<div class="col-lg-8">
		    	<form class="form-horizontal">
					<div class="form-group">
						<label class="control-label col-lg-2" style="padding-right:0;">
							{{('account.adjustaccount.startingTime' | translate) || '起始时间：'}}
						</label>
						<div class="col-lg-3">
							<datetime  [datepicker]="datepickerOpts"  name="beginTime1" [(ngModel)]="datedefault.begin" ></datetime>
						</div>
						<label class="control-label col-lg-2" style="padding-right:0">
							{{('account.adjustaccount.endingTime' | translate) || '截止时间：'}}
						</label>
						<div class="col-lg-3">
							<datetime [datepicker]="datepickerOpts" name="endTime1" [(ngModel)]="datedefault.end" ></datetime>
						</div>
						<div class="col-lg-2">
							<button class="mb-sm btn btn-primary btn-outline" type="button" (click)="initTableData()">
								{{('account.adjustaccount.inQuery' | translate) || '查 询'}}
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>

		<p-dataTable [value]="adjust" [rows]="10" [paginator]="true" [pageLinks]="3" [rowsPerPageOptions]="[5,10,20]" selectionMode="single" (onRowSelect)="onRowSelect($event)">
			<p-column [style]="{'width':'30px'}" selectionMode="single"></p-column>
		    <p-column field="total_id" header="{{('account.adjustaccount.totalId' | translate) || '结算单编号'}}" [style]="{'text-align':'center','width':'20%'}">
		    	<ng-template let-col let-adjust="rowData" pTemplate="body">
		            <span style="word-break:break-all;">{{adjust[col.field]}}</span>
		        </ng-template>
		    </p-column>
		    <p-column field="create_time" header="{{('account.adjustaccount.createTime' | translate) || '生成日期'}}" [style]="{'text-align':'center'}"></p-column>
		    <p-column field="chnl_name" header="{{('account.adjustaccount.chnlName' | translate) || '渠道名称'}}" [style]="{'text-align':'center'}"></p-column>
		    <p-column field="start_date" header="{{('account.adjustaccount.startDate' | translate) || '账单开始日期'}}" [style]="{'text-align':'center'}"></p-column>
		    <p-column field="end_date" header="{{('account.adjustaccount.endDate' | translate) || '账单结束日期'}}" [style]="{'text-align':'center'}"></p-column>
		    <p-column field="fee" header="{{('account.adjustaccount.fee' | translate) || '结算单金额'}}" [style]="{'text-align':'center'}">
		    	<ng-template let-col let-adjust="rowData" pTemplate="body">
		            <span style="word-break:break-all;">{{('account.adjustaccount.yuan' | translate) || '¥'}}{{adjust[col.field] |number:'1.2-2'}}</span>
		        </ng-template>		    	
		    </p-column>
		    <p-column field="current_adjust_fee" header="{{('account.adjustaccount.currentAdjustFee' | translate) || '本月调账金额'}}" [style]="{'text-align':'center'}"> 
		    	<ng-template let-col let-adjust="rowData" pTemplate="body">
		            <span style="word-break:break-all;">{{('account.adjustaccount.yuan' | translate) || '¥'}}{{adjust[col.field] |number:'1.2-2'}}</span>
		        </ng-template>
		    </p-column>


		</p-dataTable>
	</div>
</div>


<div class="modal fade" bsModal #adjustacc="bs-modal" [config]="{backdrop: false}" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
 aria-hidden="true">
	<div class="modal-dialog modal-md">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" aria-label="Close" (click)="adjustacc.hide()">
                    <span aria-hidden="true">&times;</span>
                </button>
				<h4 class="modal-title">
					{{('account.adjustaccount.adjustment' | translate) || '调 账'}}
				</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" #adjustForm="ngForm">
					<div class="form-group">
						<label class="col-lg-3 control-label" for="adjust_copy.total_id">
							{{('account.adjustaccount.totalId' | translate) || '结算单编号'}}
						</label>
						<div class="col-lg-8">
          					<input class="form-control" type="text" name="adjust_copy.total_id" [(ngModel)]="adjust_copy.total_id"  [disabled]="true">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="adjust_copy.chnl_name">
							{{('account.adjustaccount.chnlName' | translate) || '渠道名称'}}
						</label>
						<div class="col-lg-8">
          					<input class="form-control" type="text" name="adjust_copy.chnl_name" [(ngModel)]="adjust_copy.chnl_name"  [disabled]="true">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="adjust_copy.fee">
							{{('account.adjustaccount.fee' | translate) || '结算单金额'}}
						</label>
						<div class="col-lg-8">
          					<input class="form-control" type="text" name="adjust_copy.fee" [(ngModel)]="adjust_copy.fee" [disabled]="true">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="adjustType">
							{{('account.adjustaccount.adjustType' | translate) || '调账类型'}}
						</label>
						<div class="col-lg-8">
          					<ng-select name="adjustType" [(ngModel)]="adjust_copy.adjust_type" #adjustSelect placeholder="{{('account.adjustaccount.adjustTypeAll.adjustOn' | translate) || '调增'}}"> </ng-select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label" for="adjustFee">
							{{('account.adjustaccount.adjustFee' | translate) || '调账金额'}}
						</label>
						<div class="col-sm-8">
							<input (input)="upDigit($event.target.value)" name="adjustFee" type="text" class="form-control" id="adjustFee" [(ngModel)]="adjust_copy.adjust_fee"
							 #adjustFee="ngModel" required autocomplete="off" placeholder="{{('account.adjustaccount.adjustFeePlace' | translate) || '请输入充值金额'}}">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-3 col-sm-8" [style.color]="adjust_copy.message.indexOf('错误')>0?'#F05050':'#169BD5'">
							{{adjust_copy.message}}
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label" for="remark">
							{{('account.adjustaccount.remark' | translate) || '调账原因'}}
						</label>
						<div class="col-sm-8">
							<textarea class="form-control" name="remark" rows="3" style="resize:none" id="remark" #remark="ngModel" [(ngModel)]="adjust_copy.remark" maxlength="100" placeholder="{{('account.adjustaccount.remarkPlace' | translate) || '不超过100个字'}}"></textarea>
						</div>
					</div>
					<div class="form-group text-right">
						<div class="col-sm-offset-7 col-sm-2">
							<button class="mb-sm btn btn-primary btn-outline" type="button" (click)="adjustacc.hide();">
								{{('account.adjustaccount.cancel' | translate) || '取消'}}
							</button>
						</div>
						<div class="col-sm-2">
							<button class="mb-sm btn btn-primary btn-outline" type="button" [disabled]="!adjustForm.form.valid||adjust_copy.able" (click)="chargeQuery()">
								{{('account.adjustaccount.confirm' | translate) || '确定'}}
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<div class="modal fade" bsModal #adjustRecords="bs-modal" [config]="{backdrop: false}" tabindex="1" role="dialog" aria-labelledby="mySmallModalLabel"
 aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content" style="top:40px">
			<div class="modal-header">
				<button type="button" class="close" aria-label="Close" (click)="adjustRecords.hide()">
                    <span aria-hidden="true">&times;</span>
                </button>
				<h4 class="modal-title">
					{{('account.adjustaccount.adjustmentRecord' | translate) || '调账记录'}}
				</h4>
			</div>
			<div class="modal-body" style="padding-bottom:0px">
				<div class="panel">
					<div class="panel-heading">
						<div class="col-lg-4"></div>
						<div class="col-lg-8">
							<form class="form-horizontal">
								<div class="form-group">
									<label class="control-label col-lg-2" style="padding-right:0;">
										{{('account.adjustaccount.startingTime' | translate) || '起始时间：'}}
									</label>
									<div class="col-lg-3">
										<datetime  [datepicker]="datepickerOpts"  name="beginTime" [(ngModel)]="dateInfo.begin"></datetime>
									</div>
									<label class="control-label col-lg-2" style="padding-right:0;">
										{{('account.adjustaccount.endingTime' | translate) || '截止时间：'}}
									</label>
									<div class="col-lg-3">
										<datetime [datepicker]="datepickerOpts" name="endTime" [(ngModel)]="dateInfo.end" ></datetime>
									</div>
									<div class="col-lg-2">
										<button class="mb-sm btn btn-primary btn-outline" type="button" (click)="searchAdjustRecords()">查 询</button>
									</div>
								</div>
							</form>
						</div>
					</div>
					<div class="panel-body">
						<p-dataTable [value]="records" [rows]="pageSize" [paginator]="true" [pageLinks]="3" reorderableColumns="true" [lazy]="true" [totalRecords]="totalRecords" (onLazyLoad)="loadData($event)" [responsive]="true">
						    <p-column field="chnl_name" header="{{('account.adjustaccount.chnlName' | translate) || '渠道名称'}}" [style]="{'text-align':'center'}">
						    </p-column>
						    <p-column field="bill_cycle_id" header="{{('account.adjustaccount.billCycleId' | translate) || '账单账期'}}" [style]="{'text-align':'center'}"></p-column>
						    <p-column field="adjust_type" header="{{('account.adjustaccount.adjustType' | translate) || '调账类型'}}" [style]="{'text-align':'center','width':'10%'}"></p-column>
						    <p-column field="adjust_fee" header="{{('account.adjustaccount.adjustFee' | translate) || '调账金额'}}" [style]="{'text-align':'center'}">
						    	<ng-template let-col let-adjust="rowData" pTemplate="body">
						            <span style="word-break:break-all;">{{('account.adjustaccount.yuan' | translate) || '¥'}}{{adjust[col.field] |number:'1.2-2'}}</span>
						        </ng-template>
						    </p-column>
						    <p-column field="update_time" header="{{('account.adjustaccount.adjustmentTime' | translate) || '调账时间'}}" [style]="{'text-align':'center','width':'20%'}"></p-column>
						    <p-column field="remark" header="{{('account.adjustaccount.remark' | translate) || '调账原因'}}" [style]="{'text-align':'center'}">	    	
						    </p-column>
						</p-dataTable>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>